<template>
    <panel title="In货推荐">
        <section class="content">
            <!--第一层循环-->
            <div class="item" v-for="item in items" :key="item.catory">
                <img :src="item.catory" alt="">
                <section class="list">
                    <!--第二次循环商品-->
                    <div class="product" v-for="product in item.list" :key="product.img">
                        <img :src="product.img" alt="">
                        <h4 class="title">{{ product.title }}</h4>
                        <p class="price"><em>{{ product.price }}</em>起</p>
                        <article>
                            <div class="wrapper">
                                <!--这里新增个width的样式,根据数据来变化,并且设置最大宽度100%,这样不会超出-->
                                <div class="inner" :style="{width:product.progress + '%'}"></div>
                            </div>
                            <p>{{ product.progress }}%</p>
                        </article>
                        <!--后期这里可以通过数据if来判断是否显示-->
                        <label>精选</label>
                    </div>
                </section>
            </div>
        </section>

    </panel>
</template>

<script>
    import Panel from "../core/panel";

    export default {
        components: {Panel},
        data() {
            return {
                items: [{
                    catory: "//img12.360buyimg.com/jrpmobile/jfs/t3406/210/2247820735/50952/86016eea/5846d8e7N20446dbd.png?width=750&height=200",
                    list: [{
                        img: "https://img30.360buyimg.com/cf/s250x250_jfs/t14881/283/656508232/143980/9b606acf/5a33a171N18c9c80a.jpg",
                        title: "双响炮蓝牙音箱",
                        price: "29.00",
                        progress: 60,
                    }, {
                        img: "https://img30.360buyimg.com/cf/s250x250_jfs/t15529/308/632300625/135123/adb9c6d0/5a37676dNc31da9ea.jpg",
                        title: "脑波相机",
                        price: "998.00",
                        progress: 259,
                    }],
                }, {
                    catory: "//img12.360buyimg.com/jrpmobile/jfs/t3739/82/2244582797/54399/746c7d79/5846a953N66b67d05.png?width=750&height=200",
                    list: [{
                        img: "https://img30.360buyimg.com/cf/s250x250_jfs/t11257/287/2281727659/55759/e00b90a/5a138f21N32dca834.jpg",
                        title: "智能电动牙刷",
                        price: "19.00",
                        progress: 481,
                    }, {
                        img: "https://img30.360buyimg.com/cf/s250x250_jfs/t14209/293/662014092/61635/bba5c330/5a33a983N077cac56.jpg",
                        title: "烟草加热电子烟",
                        price: "258.00",
                        progress: 105,
                    }],
                }, {
                    catory: "//img12.360buyimg.com/jrpmobile/jfs/t3214/113/4408032436/61548/ce316eef/5846d310Ne93f00c9.png?width=750&height=200",
                    list: [{
                        img: "https://img30.360buyimg.com/cf/s250x250_jfs/t15007/47/884045069/149879/17987250/5a3cb182N15868ea1.jpg",
                        title: "赖公高淮封藏老酒",
                        price: "99.00",
                        progress: 199,
                    }, {
                        img: "https://img30.360buyimg.com/cf/s250x250_jfs/t14197/160/546457496/134173/4e1baccd/5a30ccc5Na44f7492.jpg",
                        title: "泗洪花雕醉蟹",
                        price: "58.00",
                        progress: 222,
                    }],
                }],
            }
        }
    }
</script>

<style scoped lang="scss">
    @import "../../assets/styles/element";

    .content {
        /*抬头图片区域*/
        .item {
            > img {
                height: 85px;
                width: 100%;
                display: block;

            }

            /*商品列表区域*/
            .list {
                @include flex(row);

                .product {
                    width: 50%;
                    height: 198px;
                    box-sizing: border-box;
                    text-align: center;
                    background: rgba(0, 0, 0, .02);
                    position: relative;

                    img {
                        width: 90px;
                        height: 90px;
                        margin: 22px auto 10px;
                    }

                    .title {
                        font-family: PingFangSC-Medium;
                        font-size: 14px;
                        color: #444;
                    }

                    .price {
                        font-family: PingFangSC-Semibold;
                        font-size: 10px;
                        color: #999;

                        em {
                            font-size: 18px;
                            color: #FF3232;
                            height: 24px;
                            line-height: 24px;
                            margin-right: 4px;
                        }

                        em:before {
                            content: "¥";
                            font-size: 14px;
                        }

                    }

                    /*销售量区域*/
                    article {
                        @include flex(row);
                        height: 15px;
                        justify-content: space-around;
                        align-items: center;
                        padding: 0 10px;
                        line-height: 15px;
                        margin-top: 8px;

                        .wrapper {
                            width: 72px;
                            height: 5px;
                            background: #f6e6e6;
                            border-radius: 11px;

                            .inner {
                                width: 20%;
                                max-width: 100%;
                                height: 5px;
                                background-image: linear-gradient(270deg, #F55 1%, #FF9C31 100%);
                                border-radius: 22px;
                            }
                        }

                        p {
                            font-size: 12px;
                            color: #999;
                        }
                    }
                    label{
                        position: absolute;
                        left: 0;
                        top: 0;
                        font-family: PingFangSC-Medium;
                        font-size: 10px;
                        color: #ff0000;
                        text-align: center;
                        padding: 2px 4px;
                        background-image: linear-gradient(-35deg,#C1C1C1 0,#ACACAC 100%);

                    }


                }
            }
        }
    }
</style>
